package org.snail.spring.boot.autoconfigure;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author MR.LHL
 * @date 2023/9/28
 */
@Configuration
@EnableConfigurationProperties(SnailProperties.class)
@ConditionalOnClass(SnailService.class)
public class SnailAutoConfiguration {

    @Autowired
    private SnailProperties snailProperties;
    @Bean
    @ConditionalOnProperty(prefix = "snail",name = "enable",havingValue = "true",matchIfMissing = true)
    public SnailService snailService(){
        return new SnailService(snailProperties);
    }
}
